//
//  UIBarButtonItem+XMGExtension.m
//  百思不得解国内
//
//  Created by sunnyday on 16/5/17.
//  Copyright © 2016年 sunnyday. All rights reserved.
//

#import "UIBarButtonItem+XMGExtension.h"

@implementation UIBarButtonItem (XMGExtension)

+ (instancetype)itemWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action {
    
    
    // 设置左边的按钮   initWithCustomView   自定义 控件
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    // 高亮
    [button setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    // 位置
    button.size = button.currentBackgroundImage.size;
    // 添加  按钮点击事件
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[self alloc]initWithCustomView:button];
}




@end
